import os

def generate_path2label_txt(directory_path, output_file):
    with open(output_file, 'w') as f:
        for filename in os.listdir(directory_path):
            if filename.lower().endswith(('.jpg', '.jpeg', '.png', '.gif', '.bmp')):
                image_path = os.path.join(directory_path, filename)
                label = 0  # 默认标签为0
                f.write(f"{image_path} {label}\n")

if __name__ == "__main__":
    target_directory = "E:/face_reco/capture/bk_train"
    output_txt_file = "E:/face_reco/capture/bk_train_path2label.txt"
    generate_path2label_txt(target_directory, output_txt_file)
